package com.mk.admin.service.impl;

import com.mk.admin.mapper.DoctorScienceInfoLikesMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.DoctorScienceInfoLikesEntity;
import com.mk.admin.model.query.DoctorScienceInfoLikesQuery;
import com.mk.admin.model.vo.DoctorScienceInfoLikesVo;
import com.mk.admin.service.DoctorScienceInfoLikesService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorScienceInfoLikesServiceImpl implements DoctorScienceInfoLikesService {
    @Autowired
    private DoctorScienceInfoLikesMapper doctorScienceInfoLikesMapper;

    @Override
    public ResultDto select(DoctorScienceInfoLikesQuery query) {
        DoctorScienceInfoLikesEntity entity = JSONCopy.copy(query, DoctorScienceInfoLikesEntity.class);
        return ResultDto.data(doctorScienceInfoLikesMapper.count(entity), doctorScienceInfoLikesMapper.select(entity));
    }

    @Override
    public ResultDto add(DoctorScienceInfoLikesVo doctorScienceInfoLikesVo) {
        DoctorScienceInfoLikesEntity entity = JSONCopy.copy(doctorScienceInfoLikesVo, DoctorScienceInfoLikesEntity.class);
        return ResultDto.data(doctorScienceInfoLikesMapper.insert(entity));
    }

    @Override
    public ResultDto update(DoctorScienceInfoLikesVo doctorScienceInfoLikesVo) {
        DoctorScienceInfoLikesEntity entity = JSONCopy.copy(doctorScienceInfoLikesVo, DoctorScienceInfoLikesEntity.class);
        return ResultDto.data(doctorScienceInfoLikesMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(doctorScienceInfoLikesMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(doctorScienceInfoLikesMapper.status(id));
    }
}
